package com.playball.lottery.frm.yhzx;

import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
import java.util.Map;

import org.json.JSONException;
import org.json.JSONObject;
import org.json.JSONTokener;

import com.playball.lottery.ApplicationData;
import com.playball.lottery.R;
import com.playball.lottery.customview.ShowTipDialog;
import com.playball.lottery.nt.GetRequestParams;
import com.playball.lottery.util.ConvertJsonToList;

import android.app.Activity;
import android.app.DatePickerDialog;
import android.os.AsyncTask;
import android.os.Bundle;
import android.util.Log;
import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
import android.view.View.OnClickListener;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.BaseAdapter;
import android.widget.Button;
import android.widget.DatePicker;
import android.widget.EditText;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.Spinner;
import android.widget.TextView;
import android.widget.Toast;
import android.widget.AdapterView.OnItemSelectedListener;

public class MyYongJin extends Activity {
	
	TextView tv_my_huiyuan_lottery,tv_my_huiyuan_tips;
	Spinner spn_my_huiyuan_lottery,sbt_my_huiyuan_sdate,sbt_my_huiyuan_edate;
	Button bt_my_huiyuan_sdate,bt_my_huiyuan_edate;
	Button bt_my_huiyuan_search,bt_my_huiyuan_search1,
	bt_my_huiyuan_jiaoyimingxi,bt_my_huiyuan_jiaoyihuizong,bt_my_huiyuan_wodexiaji;
	EditText et_my_huiyuan_userName;
	ListView lv_my_huiyuan;
	/**
	 * 0,我的下级 1，交易汇总 2，交易明细
	 */
	int showType = 0;
	/**
	 * 选择的彩种ID
	 */
	String selectLotId;
	
	View view_wodxiaji,view_jiaoyimingxi,view_jiaoyihuizong,view1,view2,view3;
	private MyYongJin context;
	
	
	/** 填充到listview的本地数据 */
	private List<Map<String, Object>> mDataList;
	/** 网络获取的数据 */
	private List<Map<String, Object>> netDataList;
	/** 投注记录适配器 */
	private MyYongJinListAdapter recordAdapter;
	
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		requestWindowFeature(Window.FEATURE_NO_TITLE);
		setContentView(R.layout.layout_my_yongjin);
		this.context = this;
		titleBar();
		Calendar.getInstance().get(Calendar.YEAR);
		years = new String[]{""+(Calendar.getInstance().get(Calendar.YEAR)-2),""+(Calendar.getInstance().get(Calendar.YEAR)-1),""+Calendar.getInstance().get(Calendar.YEAR)};
		selectYear = ""+Calendar.getInstance().get(Calendar.YEAR);
		selectMonth = ""+((Calendar.getInstance().get(Calendar.MONTH)+1)<10 ?"0"+(Calendar.getInstance().get(Calendar.MONTH)+1):(Calendar.getInstance().get(Calendar.MONTH)+1));
		et_my_huiyuan_userName = (EditText) findViewById(R.id.et_my_huiyuan_userName);
		tv_my_huiyuan_lottery = (TextView) findViewById(R.id.tv_my_huiyuan_lottery);
		tv_my_huiyuan_tips = (TextView) findViewById(R.id.tv_my_huiyuan_tips);
		spn_my_huiyuan_lottery = (Spinner) findViewById(R.id.bt_my_huiyuan_lottery);
		sbt_my_huiyuan_sdate = (Spinner) findViewById(R.id.sbt_my_huiyuan_sdate);
		sbt_my_huiyuan_edate = (Spinner) findViewById(R.id.sbt_my_huiyuan_edate);
		bt_my_huiyuan_sdate = (Button) findViewById(R.id.bt_my_huiyuan_sdate);
		bt_my_huiyuan_edate = (Button) findViewById(R.id.bt_my_huiyuan_edate);
		bt_my_huiyuan_search = (Button) findViewById(R.id.bt_my_huiyuan_search);
		bt_my_huiyuan_search1 = (Button) findViewById(R.id.bt_my_huiyuan_search1);
		bt_my_huiyuan_jiaoyimingxi = (Button) findViewById(R.id.bt_my_huiyuan_jiaoyimingxi);
		bt_my_huiyuan_jiaoyihuizong = (Button) findViewById(R.id.bt_my_huiyuan_jiaoyihuizong);
		bt_my_huiyuan_wodexiaji = (Button) findViewById(R.id.bt_my_huiyuan_wodexiaji);
		lv_my_huiyuan = (ListView) findViewById(R.id.lv_my_huiyuan);
		view_wodxiaji=findViewById(R.id.view_wodxiaji);
		view_jiaoyimingxi = findViewById(R.id.view_jiaoyimingxi);
		view_jiaoyihuizong = findViewById(R.id.view_jiaoyihuizong);
		view1 = findViewById(R.id.view_my_yj_1);
		view2 = findViewById(R.id.view_my_yj_2);
		view3 = findViewById(R.id.view_my_yj_3);
		
		String[] lotterArr = getResources().getStringArray(R.array.my_huiyuan_lottery);
		ArrayAdapter<String> lottAdapter = new ArrayAdapter<String>(this, R.layout.simple_spinner_item, android.R.id.text1, lotterArr);
		lottAdapter.setDropDownViewResource(R.layout.simple_spinner_item);
		
		bt_my_huiyuan_search.setOnClickListener(new OnClickListener() {
			@Override
			public void onClick(View arg0) {
				startRecordThread();
			}
		});
		bt_my_huiyuan_search1.setOnClickListener(new OnClickListener() {
			@Override
			public void onClick(View arg0) {
				startRecordThread();
			}
		});
		spn_my_huiyuan_lottery.setSelection(0);
		spn_my_huiyuan_lottery.setAdapter(lottAdapter);
		spn_my_huiyuan_lottery.setOnItemSelectedListener(new OnItemSelectedListener() {
            @Override
            public void onItemSelected(AdapterView<?> parent, View view, 
                    int pos, long id) {
                String[] languages = getResources().getStringArray(R.array.my_huiyuan_lottery_id);
                selectLotId = languages[pos];
            }
            @Override
            public void onNothingSelected(AdapterView<?> parent) {
            }
        });
		
		ArrayAdapter<String> yearAdapter = new ArrayAdapter<String>(this, R.layout.simple_spinner_item, android.R.id.text1, years);
		yearAdapter.setDropDownViewResource(R.layout.simple_spinner_item);
		sbt_my_huiyuan_sdate.setAdapter(yearAdapter);
		sbt_my_huiyuan_sdate.setOnItemSelectedListener(new OnItemSelectedListener() {
            @Override
            public void onItemSelected(AdapterView<?> parent, View view, 
                    int pos, long id) {
                selectYear = years[pos];
            }
            @Override
            public void onNothingSelected(AdapterView<?> parent) {
            }
        });
		
		ArrayAdapter<String> monthAdapter = new ArrayAdapter<String>(this, R.layout.simple_spinner_item, android.R.id.text1, months);
		monthAdapter.setDropDownViewResource(R.layout.simple_spinner_item);
		sbt_my_huiyuan_edate.setAdapter(monthAdapter);
		sbt_my_huiyuan_edate.setOnItemSelectedListener(new OnItemSelectedListener() {
            @Override
            public void onItemSelected(AdapterView<?> parent, View view, 
                    int pos, long id) {
                selectMonth = ""+pos;
            }
            @Override
            public void onNothingSelected(AdapterView<?> parent) {
            }
        });
		

		bt_my_huiyuan_sdate.setOnClickListener(new View.OnClickListener() {
			@Override
			public void onClick(View arg0) {
				DatePickerDialog dpd = new DatePickerDialog(MyYongJin.this, new DatePickerDialog.OnDateSetListener() {
		            @Override
		            public void onDateSet(DatePicker view, int year, int month, int day) {
		                smYear = year;
		                smMonth = month;
		                smDay = day;
		                //更新EditText控件日期 小于10加0 
		                bt_my_huiyuan_sdate.setText(new StringBuilder().append(smYear).append("-")
			                    .append((smMonth + 1) < 10 ? 0 + (smMonth + 1) : (smMonth + 1))
			                    .append("-")
			                    .append((smDay < 10) ? 0 + smDay : smDay));
		            }
		        }, smYear, smMonth,
		        smDay );
				dpd.show();
			}
		});
		
		bt_my_huiyuan_edate.setOnClickListener(new View.OnClickListener() {
			@Override
			public void onClick(View arg0) {
				DatePickerDialog dpd = new DatePickerDialog(MyYongJin.this, new DatePickerDialog.OnDateSetListener() {
		            @Override
		            public void onDateSet(DatePicker view, int year, int month, int day) {
		                emYear = year;
		                emMonth = month;
		                emDay = day;
		                //更新EditText控件日期 小于10加0 
		                bt_my_huiyuan_edate.setText(new StringBuilder().append(emYear).append("-")
			                    .append((emMonth + 1) < 10 ? 0 + (emMonth + 1) : (emMonth + 1))
			                    .append("-")
			                    .append((emDay < 10) ? 0 + emDay : emDay));
		            }
		        }, emYear, emMonth,
		        emDay);//.show();
				dpd.getDatePicker().setMaxDate(new Date().getTime());
				dpd.show();
			}
		});

		bt_my_huiyuan_wodexiaji.setEnabled(false);
		setBtnOnClick(R.id.bt_my_huiyuan_jiaoyihuizong);
		setBtnOnClick(R.id.bt_my_huiyuan_jiaoyimingxi);
		setBtnOnClick(R.id.bt_my_huiyuan_wodexiaji);
		getShowType(R.id.bt_my_huiyuan_wodexiaji);
		startRecordThread();
	}
	
	private Calendar calendar;
    private int smYear;
    private int smMonth;
    private int smDay;
    
    private int emYear;
    private int emMonth;
    private int emDay;
    
    private String[] years;
    private String[] months = {"全部","1","2","3","4","5","6","7","8","9","10","11","12"};
    private String selectYear;
    private String selectMonth;
	
	private void setBtnOnClick(final int btnId) {
		Button btn = (Button) findViewById(btnId);
		btn.setOnClickListener(new OnClickListener() {
			@Override
			public void onClick(View v) {
				showType = getShowType(btnId);
				startRecordThread();
			}
		});
		
	}
	
	public int getShowType(int btnId) {
	
		int id = 0;
		// 恢复默认
		((Button) findViewById(R.id.bt_my_huiyuan_wodexiaji)).setEnabled(true);
		((Button) findViewById(R.id.bt_my_huiyuan_jiaoyihuizong)).setEnabled(true);// setBackgroundResource(R.drawable.yhzx_retrecord_center01);
		((Button) findViewById(R.id.bt_my_huiyuan_jiaoyimingxi)).setEnabled(true);// setBackgroundResource(R.drawable.yhzx_retrecord_center01);
		view_jiaoyihuizong.setVisibility(View.GONE);
		view_jiaoyimingxi.setVisibility(View.GONE);
		view_wodxiaji.setVisibility(View.GONE);
		view1.setVisibility(View.VISIBLE);
		view2.setVisibility(View.GONE);
		view3.setVisibility(View.VISIBLE);
		sbt_my_huiyuan_edate.setSelection(Calendar.getInstance().get(Calendar.MONTH)+1);
		sbt_my_huiyuan_sdate.setSelection(2);
		switch (btnId) {
		case R.id.bt_my_huiyuan_wodexiaji:
			view3.setVisibility(View.VISIBLE);
			view_wodxiaji.setVisibility(View.VISIBLE);
			tv_my_huiyuan_lottery.setVisibility(View.VISIBLE);
			spn_my_huiyuan_lottery.setVisibility(View.VISIBLE);
	        calendar = Calendar.getInstance();
	        emYear = calendar.get(Calendar.YEAR);
	        emMonth = calendar.get(Calendar.MONTH);
	        emDay = calendar.get(Calendar.DAY_OF_MONTH);
	        calendar.add(Calendar.MONTH, -3);;
	        smYear = calendar.get(Calendar.YEAR);
	        smMonth = calendar.get(Calendar.MONTH);
	        smDay = calendar.get(Calendar.DAY_OF_MONTH);
	        bt_my_huiyuan_sdate.setText(new StringBuilder().append(smYear).append("-")
	                .append((smMonth + 1) < 10 ? 0 + (smMonth + 1) : (smMonth + 1))
	                .append("-")
	                .append((smDay < 10) ? 0 + smDay : smDay));
	        bt_my_huiyuan_edate.setText(new StringBuilder().append(emYear).append("-")
	                .append((emMonth + 1) < 10 ? 0 + (emMonth + 1) : (emMonth + 1))
	                .append("-")
	                .append((emDay < 10) ? 0 + emDay : emDay));
			id = 0;
			((Button) findViewById(R.id.bt_my_huiyuan_wodexiaji)).setEnabled(false);// setBackgroundResource(R.drawable.yhzx_retrecord_left02);
			break;
		case R.id.bt_my_huiyuan_jiaoyihuizong:
			view2.setVisibility(View.VISIBLE);
			view_jiaoyihuizong.setVisibility(View.VISIBLE);
			tv_my_huiyuan_lottery.setVisibility(View.VISIBLE);
			spn_my_huiyuan_lottery.setVisibility(View.VISIBLE);
	        calendar = Calendar.getInstance();
	        emYear = calendar.get(Calendar.YEAR);
	        emMonth = calendar.get(Calendar.MONTH);
	        emDay = calendar.get(Calendar.DAY_OF_MONTH);
	        calendar.add(Calendar.DAY_OF_MONTH, -6);;
	        smYear = calendar.get(Calendar.YEAR);
	        smMonth = calendar.get(Calendar.MONTH);
	        smDay = calendar.get(Calendar.DAY_OF_MONTH);
	        bt_my_huiyuan_sdate.setText(new StringBuilder().append(smYear).append("-")
	                .append((smMonth + 1) < 10 ? 0 + (smMonth + 1) : (smMonth + 1))
	                .append("-")
	                .append((smDay < 10) ? 0 + smDay : smDay));
	        bt_my_huiyuan_edate.setText(new StringBuilder().append(emYear).append("-")
	                .append((emMonth + 1) < 10 ? 0 + (emMonth + 1) : (emMonth + 1))
	                .append("-")
	                .append((emDay < 10) ? 0 + emDay : emDay));
			id = 1;
			((Button) findViewById(R.id.bt_my_huiyuan_jiaoyihuizong)).setEnabled(false);// setBackgroundResource(R.drawable.yhzx_retrecord_center02);
			break;
		case R.id.bt_my_huiyuan_jiaoyimingxi:
			view1.setVisibility(View.VISIBLE);
			view2.setVisibility(View.VISIBLE);
			view_jiaoyimingxi.setVisibility(View.VISIBLE);
			tv_my_huiyuan_lottery.setVisibility(View.VISIBLE);
			spn_my_huiyuan_lottery.setVisibility(View.VISIBLE);
			calendar = Calendar.getInstance();
	        emYear = calendar.get(Calendar.YEAR);
	        emMonth = calendar.get(Calendar.MONTH);
	        emDay = calendar.get(Calendar.DAY_OF_MONTH);
	        calendar.add(Calendar.DAY_OF_MONTH, -6);;
	        smYear = calendar.get(Calendar.YEAR);
	        smMonth = calendar.get(Calendar.MONTH);
	        smDay = calendar.get(Calendar.DAY_OF_MONTH);
			id = 2;
			((Button) findViewById(R.id.bt_my_huiyuan_jiaoyimingxi)).setEnabled(false);// setBackgroundResource(R.drawable.yhzx_retrecord_center02);
			break;
		}
		return id;
	}
	
	
	
	public class MyYongJinListAdapter extends BaseAdapter {
		private List<Map<String, Object>> mData;
		private LayoutInflater mInflater;
		public MyYongJinListAdapter(List<Map<String, Object>> appData) {
			mData = appData;
			this.mInflater = LayoutInflater.from(context);
		}
		@Override
		public int getCount() {
			return mData.size();
		}
		@Override
		public Object getItem(int arg0) {
			return mData.get(arg0);
		}
		@Override
		public long getItemId(int arg0) {
			return arg0;
		}
		public View getView(final int position, View convertView, final ViewGroup parent) {
			ViewHolder holder = null;
			if (convertView == null) {
				holder = new ViewHolder();
				convertView = mInflater.inflate(R.layout.item_woxiaji, null);
				holder.tv_item_1 = (TextView) convertView.findViewById(R.id.tv_item_1);
				holder.tv_item_2 = (TextView) convertView.findViewById(R.id.tv_item_2);
				holder.tv_item_3 = (TextView) convertView.findViewById(R.id.tv_item_3);
				holder.tv_item_4 = (TextView) convertView.findViewById(R.id.tv_item_4);
				holder.tv_item_5 = (TextView) convertView.findViewById(R.id.tv_item_5);
				holder.line3 = convertView.findViewById(R.id.view_item_line3);
				holder.line4 = convertView.findViewById(R.id.view_item_line4);
				holder.line5 = convertView.findViewById(R.id.view_item_line5);
				holder.view_item_myhuiyuan = (LinearLayout) convertView.findViewById(R.id.view_item_myhuiyuan);
				if(showType == 0){
					holder.line5.setVisibility(View.GONE);
					holder.tv_item_5.setVisibility(View.GONE);
					holder.line4.setVisibility(View.GONE);
					holder.tv_item_4.setVisibility(View.GONE);
				}else if(showType == 1){
					holder.line3.setVisibility(View.GONE);
					holder.tv_item_3.setVisibility(View.GONE);
					holder.line4.setVisibility(View.GONE);
					holder.tv_item_4.setVisibility(View.GONE);
					holder.line5.setVisibility(View.GONE);
					holder.tv_item_5.setVisibility(View.GONE);
					
				}
				convertView.setTag(holder);
			} else {
				holder = (ViewHolder) convertView.getTag();
			}
			if(showType == 0){
				holder.tv_item_1.setText(selectYear+"年"+mData.get(position).get("Month").toString()+"月");
				holder.tv_item_2.setText(String.format("%.2f", Float.parseFloat(mData.get(position).get("Sales").toString())));
				holder.tv_item_3.setText(String.format("%.2f", Float.parseFloat(mData.get(position).get("Bonus").toString())));
			}else if(showType == 1){
				holder.tv_item_1.setText(mData.get(position).get("LottName").toString());
				holder.tv_item_2.setText(mData.get(position).get("Scale").toString()+"%");
			}else{
				holder.tv_item_1.setText(mData.get(position).get("DateTime").toString());
				holder.tv_item_2.setText(mData.get(position).get("Bouns").toString());
				holder.tv_item_3.setText(mData.get(position).get("LottName").toString());
				holder.tv_item_4.setText(mData.get(position).get("Money").toString());
				holder.tv_item_5.setText(mData.get(position).get("UserName").toString());
			}
			return convertView;
		}

		public class ViewHolder {
			// 线性布局
			public LinearLayout view_item_myhuiyuan;
			public TextView tv_item_1;
			public TextView tv_item_2;
			public TextView tv_item_3;
			public TextView tv_item_4;
			public TextView tv_item_5;
			public View line3;
			public View line4;
			public View line5;
		}
	}
	
	public void startRecordThread() {
		AsyncLoader task = new AsyncLoader();
		String[] dyn = new String[2];
		JSONObject params = new JSONObject();
		try {
			if(showType == 0){
//				{"year":"2016","month":"12"}
				params.put("year", selectYear);
				params.put("month", selectMonth);
			}else if(showType == 1){

			}else{
//				{"lotteryid":"0","enddate":"2016-11-16","username":"","pageSize":"1000000","pageIndex":"1","startdate":"2016-11-10"}
				params.put("lotteryid", ""+selectLotId);
				params.put("enddate", bt_my_huiyuan_edate.getText().toString());
				params.put("username", et_my_huiyuan_userName.getText().toString().trim());
				params.put("pageIndex", "1");
				params.put("startdate", bt_my_huiyuan_sdate.getText().toString());
				params.put("pageSize", "1000000");
			}
			
		} catch (JSONException ex) {
			Log.e("error", ex.toString());
		}
		dyn[0] = params.toString();
		dyn[1] = ""+(121+showType);
		task.execute(dyn);
	}
	
	class AsyncLoader extends AsyncTask<String, Integer, String> {// 继承AsyncTask
		String action;
		ShowTipDialog showdialog = new ShowTipDialog();
		// 1.准备运行
		protected void onPreExecute() {
			showdialog.showDialog(MyYongJin.this);
		}
		// 2.正在后台运行
		@Override
		protected String doInBackground(String... paramsArr) {
			// 处理后台执行的任务，在后台线程执行
			String strResult = null;
			action = paramsArr[1];
			String UserID = ApplicationData.getInstance().getUserID();
			strResult = GetRequestParams.getRequestUserIDResult(paramsArr[0], UserID, action, getApplicationContext());
			// 获取请求返回值
			return strResult;
		}
		// 3.进度更新
		protected void onProgressUpdate(Integer... progress) {
		}
		// 4.完成后台任务
		protected void onPostExecute(String result) {
			if (result != null) {
				try {
					JSONTokener jsonParser = new JSONTokener(result);
					JSONObject js = (JSONObject) jsonParser.nextValue();
					if (Integer.parseInt(js.getString("Code")) == 0) {
						try {
							JSONTokener jsonParser1 = new JSONTokener(result);
							JSONObject js1 = (JSONObject) jsonParser1.nextValue();
							if (js1.getString("Data") != null && !"".equals(js1.getString("Data"))) {
								List<Map<String, Object>> list = new ArrayList<Map<String, Object>>();
								
								if(showType == 0){
									list = ConvertJsonToList.getList(String.valueOf(ConvertJsonToList.getMap(
											js1.getString("Data")).get("Union")));
									netDataList = new ArrayList<Map<String, Object>>(list);
									tv_my_huiyuan_tips.setText(String.format("汇总   销量:%.2f  佣金:%.2f", 
											Float.parseFloat(String.valueOf(ConvertJsonToList.getMap(js1.getString("Data")).get("Sales"))),
											Float.parseFloat(String.valueOf(ConvertJsonToList.getMap(js1.getString("Data")).get("Bouns")))
											));
								}else if(showType == 1){
									list = ConvertJsonToList.getList(js1.getString("Data"));
									netDataList = new ArrayList<Map<String, Object>>(list);
									tv_my_huiyuan_tips.setText("");
								}else{
									list = ConvertJsonToList.getList(String.valueOf(ConvertJsonToList.getMap(
											js1.getString("Data")).get("Union")));
									netDataList = new ArrayList<Map<String, Object>>(list);
									tv_my_huiyuan_tips.setText(String.format("销量:%.2f元  佣金:%.2f元  共%s条",
											Float.parseFloat(String.valueOf(ConvertJsonToList.getMap(js1.getString("Data")).get("Money"))),
											Float.parseFloat(String.valueOf(ConvertJsonToList.getMap(js1.getString("Data")).get("Bouns"))),
											String.valueOf(ConvertJsonToList.getMap(js1.getString("Data")).get("Total"))
											));
								}
								if(list.size() <=0){
									Toast.makeText(MyYongJin.this, "没有数据！", Toast.LENGTH_LONG).show();
								}
								showList();
							} else {
								// 数据为空时为0
							}
						} catch (JSONException e) {
							// 异常处理代码
							Log.e("error", e.toString());
						}
						// 显示
						
					} else {
						Toast.makeText(MyYongJin.this, js.getString("Data"), Toast.LENGTH_SHORT).show();
					}
				} catch (JSONException ex) {
					// 异常处理代码
					Log.e("error", ex.toString());
				} finally {
					showdialog.closeDialog();
				}
			} else {
				Toast.makeText(MyYongJin.this, getString(R.string.problem_01), Toast.LENGTH_LONG).show();
			}
		}
		protected void onCancelled() {
		}

	}
	
	// TitleBar标题栏
	public void titleBar() {
		TextView info = (TextView) findViewById(R.id.top_title_info);
		info.setText("我的业绩");
		TextView back = (TextView) findViewById(R.id.top_title_back);
		back.setOnClickListener(new View.OnClickListener() {
			@Override
			public void onClick(View v) {
				MyYongJin.this.finish();
			}
		});
	}
	public void showList() {
		recordAdapter = new MyYongJinListAdapter(netDataList);
		lv_my_huiyuan.setAdapter(recordAdapter);
	}

	@Override
	public boolean onKeyDown(int keyCode, KeyEvent event) {
		if (keyCode == KeyEvent.KEYCODE_BACK) {
				this.finish();
				return true;
		} else {
			return super.onKeyDown(keyCode, event);
		}

	};
}
